var express = require('express');
const { takeOrderModel } = require('../database/model/pstodModel');
var router = express.Router()
var { postodModel } = require('../database/model/pstodModel')

router.post('/', (req, res) => {
    // console.log(req.body);
    new postodModel(req.body).save().then(result => {
        res.send({
            code: 1,
            msg: '录入成功',
            data: result
        })
    })
})
router.get('/getorder', (req, res) => {
    console.log(req.query);
    let { username } = req.query
    // console.log(username);
    postodModel.find({ username }).then(result => {
        res.send({
            code: 222,
            msg: '查看发布订单成功',
            data: result
        })
    })
})

router.post('/postorder/addorder', (req, res) => {
    // console.log(req.body);
    new takeOrderModel(req.body).save().then(result => {
        res.send({
            code: 1,
            msg: '录入成功',
            data: result
        })
    })
})

router.get('/postorder/getorderlist', (req, res) => {
    // console.log(req.query);
    let { username } = req.query
    takeOrderModel.find({ username}).then(result => {
        res.send({
            code: 222,
            msg: '录入成功',
            data: result
        })
    })
})
module.exports = router